package MemoryManager;

public class MemoryBlock {
    private boolean available;  // 1为空 0为进程
    private int pid; // 进程标识符
    private int allocated;  // 占用空间

    public boolean isAvailable() {
        return available;
    }
    public void setAvailable(boolean available) {
        this.available = available;
    }
    public int getPid() {
        return pid;
    }
    public void setPid(int pid) {
        this.pid = pid;
    }
    public int getAllocated() {
        return allocated;
    }
    public void setAllocated(int allocated) {
        this.allocated = allocated;
    }
    public MemoryBlock(int pid, int allocated) {
        available = false;
        this.pid = pid;
        this.allocated = allocated;
    }

    public MemoryBlock(int allocated) {
        available = true;
        this.allocated = allocated;
    }

    public void printInfo() {
        if (isAvailable()) {
            for (int i = 0; i < allocated; ++i)
                System.out.print('.');
        } else {
            for (int i = 0; i < allocated; ++i)
                System.out.print('#');
        }
    }
}
